local skel = fk.CreateSkill{
  name = "kpaII__tianlizhaocun",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["kpaII__tianlizhaocun"] = "天理昭存",
  [":kpaII__tianlizhaocun"] = "锁定技，出牌阶段结束时，若你此阶段使用【杀】的次数未达上限，你对自己造成1点火焰伤害或重置一名角色。",
  ["#kpaII__tianlizhaocun"] = "天理昭存：重置一名角色，或对自己造成1点火焰伤害。",

  ["$kpaII__tianlizhaocun1"] = "我是萨拉丁，信仰之善。",
  ["$kpaII__tianlizhaocun2"] = "一文不值，无价之宝。",
}

skel:addEffect(fk.EventPhaseEnd,{
  can_trigger = function (self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) and player.phase == Player.Play then
      local card = Fk:cloneCard("slash")
      local skill = card.skill
      local max = skill:getMaxUseTime(player, Player.HistoryPhase, card, nil) or 0
      local n = player:usedCardTimes("slash", Player.HistoryPhase)
      if player:usedCardTimes("slash", Player.HistoryPhase) < max then
        return true
      end
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local tos = {}
    for _,p in ipairs(room:getAlivePlayers()) do
      if p.chained then
        table.insertIfNeed(tos,p)
      end
    end
    local choose = {}
    if #tos > 0 then
      choose = room:askToChoosePlayers(player,{
        min_num = 1,
        max_num = 1,
        targets = tos,
        skill_name = skel.name,
        cancelable = true,
        prompt = "#kpaII__tianlizhaocun",
      })
    end
    if #choose > 0 then
      choose[1]:setChainState(false)
    else
      room:damage({
        from = player,
        to = player,
        damage = 1,
        damageType = fk.FireDamage,
        skillName = skel.name,
      })
    end
  end
})

return skel